
import { Form,  Button } from 'antd';
import {FormView01 } from '../../Components/MyForm/index'

/* 

getFieldError: ƒ (name)
getFieldInstance: ƒ getFieldInstance(name)
getFieldValue: ƒ (name)
getFieldWarning: ƒ (name)
getFieldsError: ƒ (nameList)
getFieldsValue: ƒ (nameList, filterFunc)
getInternalHooks: ƒ (key)
isFieldTouched: ƒ (name)
isFieldValidating: ƒ (name)
isFieldsTouched: ƒ ()
isFieldsValidating: ƒ (nameList)
resetFields: ƒ (nameList)
scrollToField: ƒ scrollToField(name)
setFields: ƒ (fields)
setFieldsValue: ƒ (store)
submit: ƒ ()
validateFields: ƒ (nameList, options)



*/


const TestForm = () => {
  const [form] = Form.useForm();

  const controlList = {
    form: form,
    data: {
      username: "小毅",
      name: "小毅",
      // auth:"作者"
    },
    // onValuesChange:(changedValues, allValues) => {
    //   console.log('change', changedValues, allValues);
    // },
    layout: {
      rows: [
        {
          layout: {},
          controlList: [
            {
              type: "String",
              controlItemParam: {
                id: 'name',
                label: '姓名',
                onChange:(a,b,c)=>{
                  console.log(11,a);
                  console.log(22,b);
                  console.log(33,c);
                  console.log("controlItemParam",this);
                }
              }
            },
            {
              type: "Number",
              controlItemParam: {
                id: "age",
                label: "年龄",
              },
            },
            {
              type: "Password",
              controlItemParam: {
                id: 'password',
                label: '密码',
              },
            },
            {
              type: "Radio",
              controlItemParam: {
                id: "hooby",
                label: "爱好",
              },
            },
            {
              type: "Search",
              controlItemParam: {
                id: "auth",
                label: "头像",
              },
            },
            {
              type: "TextArea",
              controlItemParam: {
                id: "describe",
                label: "自我介绍",
              },
            },
          ]
        },

      ]
    },
  }

  const getValues = () => {

    //  form.getFieldsValue(['name'],(aa,bb)=>{
    //     console.log(aa,bb);
    //  })
    // validateFields

    // const value = await form.validateFields(['name'])


    form.validateFields()
      .then(value => {
        console.log(value);
      })


  }
  return (
    <div>
      <FormView01  {...controlList} />
      <Button onClick={getValues}>提交</Button>
    </div>
  )
}

export default TestForm